W = 32

b = {1: 3, 0: 2}

patterns = []
seenP = {}

for i in xrange(1 << 16):
    length = 0
    currentI = 0
    for j in xrange(16):
        if i & (1 << j):
            currentI |= 1 << j
            length += 3
        else:
            length += 2
        if length == W and currentI not in seenP:
            seenP[currentI] = 1
            patterns.append(currentI)
            break
        if length > W:
            break

print len(patterns)

n = len(patterns)

edge = [[] for i in xrange(n)]

for i in xrange(n):
    pi = patterns[i]
    for j in xrange(i + 1, n):
        pj = patterns[j]
        l1, l2 = 0, 0
        dicti = {}
        for k in xrange(16):
            type1 = pi & (1 << k)
            if type1:
                l1 += 3
            else:
                l1 += 2
            if l1 == W:
               break
            dicti[l1] = 1
        good = True
        for k in xrange(16):
            type2 = pj & (1 << k)
            if type2:
                l2 += 3
            else:
                l2 += 2
            if l2 == W:
                break
            if l2 in dicti:
                good = False
                break
        if good:
            edge[i].append(j)
            edge[j].append(i)
    print i

#dp

dp = [[0 for i in xrange(n)] for j in xrange(10)]

for i in xrange(n):
    dp[0][i] = 1

for i in xrange(1, 10):
    for j in xrange(n):
        for k in edge[j]:
            dp[i][j] += dp[i-1][k]

print sum(dp[9])

print 'hello world'



